#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main()
{
	int n = 0;
	int x = 0;
	int i = 0;
	int count = 0;

	scanf("%d", &n);
	scanf("%d", &x);
	
	for (i = 1; i <= n; i++)
	{
		int j = i;
		while (j >0)
		{
			if (j % 10 == x)
			{
				count += 1;
			}
			j = j / 10;
		}
	}

	printf("%d", count);

	return 0;

}